#ifndef MUTEX_H_INCLUDED
#define MUTEX_H_INCLUDED

#ifdef WIN32
	#include <Windows.h>
#else
	#include <pthread.h>
#endif



#ifdef __cplusplus
extern "C" {
#endif

	struct mk_mutex_t
	{
		
#ifdef WIN32
		HANDLE	hMutex;
#else
		pthread_mutex_t mtx;
#endif
		int		bInited;
		long 	LockCount;
	};



	struct mk_mutex_t * mutex_create();

	long mutex_init(struct mk_mutex_t * pMutex, const  char * szMutexName);

	long mutex_open(struct mk_mutex_t * pMutex, char * szMutexName);

	long mutex_lock(struct mk_mutex_t * pMutex, long timeOut);

	long mutex_unlock(struct mk_mutex_t * pMutex);

	long mutex_destroy(struct mk_mutex_t * pMutex);



#ifdef __cplusplus
}
#endif


#endif // MUTEX_H_INCLUDED
